package com.bird.system.adapter.auth.gateway

import com.bird.system.application.auth.AuthAppGateway
import com.bird.system.application.common.pl.AuthUserInfo
import com.bird.user.client.UserClient
import org.springframework.stereotype.Component

@Component
class AuthGatewayImpl(val userClient: UserClient) : AuthAppGateway {
    /**
     * 获取用户信息
     * @param userName 用户名
     * @param password 密码
     * @return UserInfoApiRes 为null则标识用户名或者密码不存在
     * 
     */
    override fun oneUser(userName: String, password: String): AuthUserInfo? {
        return userClient.oneUser(userName, password)?.toAuthUserInfo()
    }

    /**
     * 获取用户信息
     * @param userId 用户ID
     * @return UserInfoApiRes 为null则标识用户不存在
     */
    override fun oneUser(userId: Long): AuthUserInfo? {
        return userClient.oneUser(userId)?.toAuthUserInfo()
    }

}